import { Vue, Component } from 'vue-property-decorator'
import PageContainer from '@/moduleC/components/layout/PageContainer.vue'
import { api } from '@/moduleC/api'
import store from '@/moduleC/store'
	interface UniSystemInfo extends UniApp.GetSystemInfoResult {
		statusBarHeight : number
	}

	interface OrderItem {
		orderNo : string
		orderTime : string
		merchant : string
		amount : number
		points : number
		status : number
		queueCount : number
	}

@Component({
  components: {
    PageContainer
  }
})
export default class OrderDetails extends Vue {
private billTypes : string[] = ['全部账单', '排队中', '已完成', '免单中']
		private billTypeIndex : number = 0
		private statusBarHeight : number = 0
		private navHeight : number = 0
		private orders : OrderItem[] = [
			{
				orderNo: '202412310001',
				orderTime: '2024-12-26',
				merchant: '杭州特色小笼包（赤峰长青街店）',
				amount: 180.0,
				points: 20,
				status: 1,
				queueCount: 132
			},
			{
				orderNo: '202412310001',
				orderTime: '2024-12-26',
				merchant: '杭州特色小笼包（赤峰长青街店）',
				amount: 180.0,
				points: 20,
				status: 2,
				queueCount: 132
			},
			{
				orderNo: '202412310001',
				orderTime: '2024-12-26',
				merchant: '杭州特色小笼包（赤峰长青街店）',
				amount: 180.0,
				points: 20,
				status: 3,
				queueCount: 132
			}
		]

		// Computed property
		get currentBillType() : string {
			return this.billTypes[this.billTypeIndex]
		}

		// Lifecycle hook
		onLoad() : void {
			try {
				const systemInfo = uni.getSystemInfoSync() as UniSystemInfo
				if (systemInfo.statusBarHeight !== undefined) {
					this.statusBarHeight = systemInfo.statusBarHeight
					this.navHeight = systemInfo.statusBarHeight + 44
				} else {
					// 设置默认值
					this.statusBarHeight = 20
					this.navHeight = 64
				}
			} catch (error) {
				console.error('获取系统信息失败:', error)
				// 设置默认值
				this.statusBarHeight = 20
				this.navHeight = 64
			}
		}

		// Methods
		async onBillTypeChange(e : { detail : { value : number } }) : Promise<void> {
			const index = e.detail.value
			if (this.billTypeIndex !== index) {
				this.billTypeIndex = index
				// 重新加载数据
				// await this.loadInitialData()
			}
		}

		goBack() : void {
			uni.navigateBack()
		}
}